package com.设计模式;

public class 抽象工厂
{
    public static void main(String[] args)
    {
        Provider provider = new SendMailFactory();
        Sender sender = provider.produce();
        sender.send();
    }
}

interface Provider
{
    public Sender produce();
}

interface Sender
{
    public void send();
}

class MailSender implements Sender
{

    @Override
    public void send()
    {
        System.out.println("this is a Mail Sender!");
    }
}

class SmsSender implements Sender
{

    @Override
    public void send()
    {
        System.out.println("this is a Sms Sender!");
    }
}

class SendSmsFactory implements Provider
{

    @Override
    public Sender produce()
    {
        return new SmsSender();
    }
}

class SendMailFactory implements Provider
{

    @Override
    public Sender produce()
    {
        return new MailSender();
    }
}
